package timeDemo;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
* @author jie
* @version 创建时间：2018年6月20日 下午4:48:11
* 类说明
*/
public class TimeLong {
	
	
	public static void main(String[] args) {
		String strStop= "2018-6-21 16:32:26";
		String strNow= "2018-6-21 16:32:20";
		SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        try {
		  Long ss=format.parse(strStop).getTime();
		  Long now=format.parse(strNow).getTime();
		  
		  System.out.println((ss-now));
		  System.out.println((ss-now)/1000);
		  
		} catch (ParseException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		
//		System.out.println(ConvertDateToLong("1529483220000"));
		long time = new Date(1529568900000L).getTime();
		System.out.println(new Date(1529568660000L));
//		System.out.println(ConvertDateToLong("2018-6-20 16:51:33"));
		
		new Thread(new Runnable() {
			
			@Override
			public void run() {
//				System.out.println(new Date().getTime());
				try {
					Thread.sleep(10);
//					System.err.println(new Date().getTime());
				} catch (InterruptedException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
			}
		}).start();;
//		Long convertDateToLong = ConvertDateToLong("-1");
//		System.out.println("==="+convertDateToLong);
//		System.out.println(ConvertDateToLong("-1"));
	}
	  public static Long ConvertDateToLong(String strDate){
	        if (strDate!=null&&strDate.length()==13){
	            return Long.parseLong(strDate);
	        }
	      
	        SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

	        Date d=null;
			try {
				d = format.parse(strDate);
			} catch (ParseException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	        return d.getTime();
	    }
}
